package com.yunzone.cloud.modules.controller;

import cn.hutool.setting.dialect.Props;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.PropertiesUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
public class FlowLimitController {

    @GetMapping("/testa")
    public String testa() {
        log.info("运行/testa......");
        int a=10/0;
        return "-----testa";
    }

    @GetMapping("/testb")
    public String testb() {
        return "------testb";

    }

    @GetMapping("/testHotKey")
    @SentinelResource(value="testHotKey",blockHandler = "testHotKeyBlockHandler")
    public String testHotKey(@RequestParam(value = "p1",required = false) String p1,
                             @RequestParam(value = "p2",required = false) String p2) {
        log.info("p1:"+p1);
        log.info("p2:"+p2);
        int a=10/0;
        return "------testHotKey";

    }

    public String testHotKeyBlockHandler(String p1, String p2, BlockException exception){
        return "~~~~~~testHotKeyBlockHandler~~~~~~兜底方法";
    }



}
